<template>
  <div class="d-container">
    <div>
      <span class="title">各部门采集任务总数</span>
      <gatherCont1 />
    </div>
    <div>
      <div class="catalogue-num">
        <span class="title">数据目录数</span>
        <div class="btns">
          <span class="btn" :class="{ on: curCatalogue === 1 }" @click="handleCatalogue(1)">各处室情况</span>
          <span class="btn" :class="{ on: curCatalogue === 2 }" @click="handleCatalogue(2)">各月份情况</span>
        </div>
      </div>
      <div class="content">
        <catalogueBar :value="catalogueData" :curCatalogue="curCatalogue" />
      </div>
    </div>
    <div>
      <div class="catalogue-num">
        <span class="title">无数据更新系统数</span>
        <div class="btns">
          <span class="btn" :class="{ on: curCatalogue1 === 3 }" @click="handleCatalogue1(3)">各处室情况</span>
          <span class="btn" :class="{ on: curCatalogue1 === 4 }" @click="handleCatalogue1(4)">按时长类别</span>
        </div>
      </div>
      <div class="content">
        <sysNumBar :value="sysNumBarData" :dataZoom="curCatalogue1" />
      </div>
    </div>
  </div>
</template>

<script setup>
import gatherCont1 from './gatherCont1.vue';
import catalogueBar from './charts/bar2.vue';
import sysNumBar from './charts/bar3.vue';
import { ref, reactive, onMounted } from 'vue';
import {
  GETgetdirectoriesNumberTwoRoom,
  GETgetdirectoriesNumberTwo,
  GETentriesNumNoneTwo,
  entriesNumTwoRoom,
  entriesNumTwo
} from '../../../api/index'

let curCatalogue = ref(1);
let curCatalogue1 = ref(3);
let catalogueData = reactive({
  xData: [],
  catalogue: [],
  dataCount: []
});
let sysNumBarData = reactive({
  yData: [],
  data: []
})

function handleCatalogue(index) {
  curCatalogue.value = index
  if (index == 1) {
    //数据目录数二级汇总TWO处室
    catalogueData.xData = []
    catalogueData.catalogue = []
    catalogueData.dataCount = []
    GETgetdirectoriesNumberTwoRoom().then(res => {
      console.log(res, '55555555');

      catalogueData.xData = res.data.map(item => item.name)
      catalogueData.catalogue = res.data.map(item => item.value)
    })
    entriesNumTwoRoom().then(res => {
      res.data.forEach(item => {
        catalogueData.dataCount.push(item.value)
      })
    })
  } else if (index == 2) {
    catalogueData.xData = []
    catalogueData.catalogue = []
    catalogueData.dataCount = []
    //数据目录数二级汇总TWO月份
    GETgetdirectoriesNumberTwo().then(res => {
      catalogueData.xData = res.data.map(item => item.name)
      catalogueData.catalogue = res.data.map(item => item.value)
    })
    entriesNumTwo().then(res => {
      res.data.forEach(item => {
        catalogueData.dataCount.push(item.value)
      })
    })
  }
}
function handleCatalogue1(index) {
  curCatalogue1.value = index
  if (index == 3) {
    sysNumBarData.yData = []
    sysNumBarData.data = []
    GETentriesNumNoneTwo().then(res => {
      res.data.forEach(item => {
        sysNumBarData.yData.push(item.name)
        sysNumBarData.data.push(item.value)
      })
    })
  } else if (index == 4) {
    sysNumBarData.yData = ['一周','月度','季度','半年',]
    sysNumBarData.data = [5,2,5,8,10]

  }
}

onMounted(() => {
  // initData()
  handleCatalogue(curCatalogue.value)
  handleCatalogue1(curCatalogue1.value)
})
</script>

<style scoped lang="scss">
.d-container {
  height: 100%;
  display: flex;
  justify-content: space-between;
  padding: 40px 10px 10px;
  box-sizing: border-box;

  p {
    padding: 0;
    margin: 0;
  }

  >div {
    width: 32.5%;
    padding: 20px 10px 10px;
    box-sizing: border-box;
    border-radius: 4px;
    background-color: rgba(11, 44, 106, 0.6);

    .title {
      position: relative;
      display: block;
      height: 26px;
      padding-left: 20px;
      font-size: 16px;
      font-weight: bold;
      color: transparent;
      background-image: linear-gradient(to bottom, #fff, #98BBFF);
      -webkit-background-clip: text;
      background-clip: text;

      &:before {
        content: '';
        position: absolute;
        width: 10px;
        height: 10px;
        left: 0;
        top: 7px;
        background-color: #3A8FFF;
        clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
      }
    }
  }

  .catalogue-num {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .btns {
      display: flex;

      .btn {
        width: 80px;
        height: 28px;
        line-height: 28px;
        margin-left: 5px;
        color: #CFEAFF;
        font-size: 14px;
        background-color: rgba(11, 44, 106, 0.8);
        border: 1px solid #084BE7;
        border-radius: 4px;
        text-align: center;
        cursor: pointer;

        &.on {
          color: #fff;
          background-color: #103985;
          border-color: #0089E9;
        }
      }
    }
  }
}
</style>
